import React from 'react';
import {WeaErrorPage, WeaTools, WeaTable, WeaLocaleProvider} from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;
import { formatData, openLinkUrl } from '../../util/common';

//我的邮件   已废弃
class MailCom extends React.Component {
	render() {
		const { currTab, list, esetting, olist, goUrl } = this.props;
		let operHtml = null;
		let receiveUrl = goUrl +'&'+ olist.map(item => `receivemailid=${item.id}`).join('&');
		if (esetting.opershow && currTab === 'unread') {
			operHtml = <div className="mail-sparator"><font className="mail-sparator-font">{getLabel(388018,"邮件服务器上的新邮件:")}&nbsp;{olist.map(item=> <span>{item.name}({item.number})</span>)}&nbsp;<a href="javascript:void(0);" onClick={openLinkUrl.bind(this,receiveUrl)}>{getLabel(20267,"进入我的邮件收取")}</a></font></div>;
		}
		return <div>
			{list.length !== 0 ? <WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@abb33u`} columns={formatData(list[0], esetting)} showHeader={false} pagination={false} dataSource={list} size="small"/> :
				<div className = "ant-table-placeholder">
					<span> <i className = "anticon anticon-frown"></i>{getLabel(83553, '暂无数据')}</span>
				</div>
			}
			{operHtml}
		</div>
	}
}


class MyErrorHandler extends React.Component {
	render() {
		const hasErrorMsg = this.props.error && this.props.error !== "";
		return (
			<WeaErrorPage ecId={`${this && this.props && this.props.ecId || ''}_WeaErrorPage@dcwwvg`} msg={hasErrorMsg?this.props.error:getLabel(385218,"对不起，该页面异常，请联系管理员！")} />
		);
	}
}
MailCom = WeaTools.tryCatch(React, MyErrorHandler, { error: "" })(MailCom);
export default MailCom;